﻿using UnityEngine;
using System.Collections;
using UniLua;

namespace TCG.FFI
{
	public static class UnityAnimationStateLib
	{
		public static string LIB_NAME = "UnityAnimationStateLib";

		public static int mf_GetBlendMode (ILuaState luaState)
		{
			AnimationState state = LuaTools.L_CheckUData (luaState, 1, LIB_NAME) as AnimationState;
			luaState.PushInteger ((int)state.blendMode);
			return 1;
		}

		public static int mf_SetBlendMode (ILuaState luaState)
		{
			AnimationState state = LuaTools.L_CheckUData (luaState, 1, LIB_NAME) as AnimationState;
			state.blendMode = (AnimationBlendMode)luaState.ToInteger (2);
			return 0;
		}

		public static int mf_GetClip (ILuaState luaState)
		{
			AnimationState state = LuaTools.L_CheckUData (luaState, 1, LIB_NAME) as AnimationState;
			LuaTools.L_PushUserData (luaState, state.clip, UnityAnimationClipLib.LIB_NAME);
			return 1;
		}

		public static int mf_GetEnabled (ILuaState luaState)
		{
			AnimationState state = LuaTools.L_CheckUData (luaState, 1, LIB_NAME) as AnimationState;
			luaState.PushBoolean (state.enabled);
			return 1;
		}

		public static int mf_SetEnabled (ILuaState luaState)
		{
			AnimationState state = LuaTools.L_CheckUData (luaState, 1, LIB_NAME) as AnimationState;
			state.enabled = luaState.ToBoolean (2);
			return 0;
		}

		public static int mf_GetLength (ILuaState luaState)
		{
			AnimationState state = LuaTools.L_CheckUData (luaState, 1, LIB_NAME) as AnimationState;
			luaState.PushNumber (state.length);
			return 1;
		}

		public static int mf_GetName (ILuaState luaState)
		{
			AnimationState state = LuaTools.L_CheckUData (luaState, 1, LIB_NAME) as AnimationState;
			luaState.PushString (state.name);
			return 1;
		}

		public static int mf_SetName (ILuaState luaState)
		{
			AnimationState state = LuaTools.L_CheckUData (luaState, 1, LIB_NAME) as AnimationState;
			state.name = luaState.ToString (2);
			return 0;
		}

		public static int mf_GetNormalizedSpeed (ILuaState luaState)
		{
			AnimationState state = LuaTools.L_CheckUData (luaState, 1, LIB_NAME) as AnimationState;
			luaState.PushNumber (state.normalizedSpeed);
			return 1;
		}

		public static int mf_SetNormalizedSpeed (ILuaState luaState)
		{
			AnimationState state = LuaTools.L_CheckUData (luaState, 1, LIB_NAME) as AnimationState;
			state.normalizedSpeed = (float)luaState.ToNumber (2);
			return 0;
		}

		public static int mf_GetNormalizedTime (ILuaState luaState)
		{
			AnimationState state = LuaTools.L_CheckUData (luaState, 1, LIB_NAME) as AnimationState;
			luaState.PushNumber (state.normalizedTime);
			return 1;
		}

		public static int mf_SetNormalizedTime (ILuaState luaState)
		{
			AnimationState state = LuaTools.L_CheckUData (luaState, 1, LIB_NAME) as AnimationState;
			state.normalizedTime = (float)luaState.ToNumber (2);
			return 0;
		}

		public static int mf_GetSpeed (ILuaState luaState)
		{
			AnimationState state = LuaTools.L_CheckUData (luaState, 1, LIB_NAME) as AnimationState;
			luaState.PushNumber (state.speed);
			return 1;
		}

		public static int mf_SetSpeed (ILuaState luaState)
		{
			AnimationState state = LuaTools.L_CheckUData (luaState, 1, LIB_NAME) as AnimationState;
			state.speed = (float)luaState.ToNumber (2);
			return 0;
		}

		public static int mf_GetTime (ILuaState luaState)
		{
			AnimationState state = LuaTools.L_CheckUData (luaState, 1, LIB_NAME) as AnimationState;
			luaState.PushNumber (state.time);
			return 1;
		}

		public static int mf_SetTime (ILuaState luaState)
		{
			AnimationState state = LuaTools.L_CheckUData (luaState, 1, LIB_NAME) as AnimationState;
			state.time = (float)luaState.ToNumber (2);
			return 0;
		}

		public static int mf_GetWeight (ILuaState luaState)
		{
			AnimationState state = LuaTools.L_CheckUData (luaState, 1, LIB_NAME) as AnimationState;
			luaState.PushNumber (state.weight);
			return 1;
		}

		public static int mf_SetWeight (ILuaState luaState)
		{
			AnimationState state = LuaTools.L_CheckUData (luaState, 1, LIB_NAME) as AnimationState;
			state.weight = (float)luaState.ToNumber (2);
			return 0;
		}

		public static int mf_GetWrapMode (ILuaState luaState)
		{
			AnimationState state = LuaTools.L_CheckUData (luaState, 1, LIB_NAME) as AnimationState;
			luaState.PushInteger ((int)state.wrapMode);
			return 1;
		}

		public static int mf_SetWrapMode (ILuaState luaState)
		{
			AnimationState state = LuaTools.L_CheckUData (luaState, 1, LIB_NAME) as AnimationState;
			state.wrapMode = (WrapMode)luaState.ToInteger (2);
			return 0;
		}
	}
}